home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 7 / FM Towns Free Software Collection 7.iso / t_os / gpen32k / source.exe / LIB / OSRC / SPRLOAD.C < prev    next >
C/C++ Source or Header  |  1993-03-22  |  749b  |  37 lines

  1. /***********************************************
  2.     システムスプライトローダ
  3.                     Copyright(C) 1993 Okome
  4. ***********************************************/
  5.  
  6. #include    <stdio.h>
  7. #include    <string.h>
  8. #include    <EGB.h>
  9. #include    <normlib.h>
  10.  
  11. int sprload( char *na, int xa, int ya )
  12. {
  13.     int i, xb, yb, xs, ys, l;
  14.     char da[1024];
  15.     FILE *fp;
  16.  
  17.     if ((fp = fopen( na, "rb" ))==NULL)
  18.         return (-1);
  19.     fread( da, 1, 16, fp );
  20.     if (strcmp(da, "SPRITE")==0)
  21.     {
  22.         xs = WORD(da + 10);
  23.         ys = WORD(da + 12);
  24.         l = WORD(da + 14);
  25.         for ( i = 0; i < l; i++ )
  26.         {
  27.             xb = i % 8;
  28.             yb = i / 8;
  29.             fread( da, 1, xs*ys*2+2, fp );
  30.             egbput( xa+xs*xb, ya+ys*yb,
  31.                     xa+xs*(xb+1)-1, ya+ys*(yb+1)-1, &da[2] );
  32.         }
  33.     }
  34.     fclose(fp);
  35.     return (0);
  36. }
  37.